/**
 * Created by zhangzhihao on 2016/12/06 11:00;
 */
var vm = new Vue({
    el: "#main",
    data: {
        id: "",
        businessNo: "",
        friendprovince: {},
        user_info: {},
        dispute_recourse: "",
        dispute_stats: "",
        selectedVal: '',
        // itemList: [
        //     { value: '1', name: '解决中' },
        //     { value: '2', name: '已解决' }
        // ]
    },
    mounted: function() {
        const _this = this;
        console.log(this.selectedVal)
        var query = window.location.search.substring(1);
        var vars = query.split("&");
        var id = "";
        var businessNo = "";
        console.log(id);
        for (var i = 0; i < vars.length; i++) {
            var pair = vars[i].split("=");
            if (pair[0] == "id") {
                id = pair[1];
                _this.id = id;
            }
            if (pair[0] == "businessNo") {
                businessNo = pair[1];
                _this.businessNo = businessNo;
            }
        }
        _this.modinit();
    },
    methods: {
        //修改进入初始化
        modinit: function() {
            const _this = this;
            let obj = {
                appliName: _this.appliName,
                businessNo: _this.businessNo, //业务识别号（保单号）
            };
            axios({
                    method: "post",
                    url: App.envUrl.backtrackUrl+"collect/queryDataList",
                    data: obj,
                })
                .then((data) => {
                    _this.user_info = data.data.pageCount.datas[0];
                    _this.selectedVal = _this.user_info.friend_status
                    _this.dispute_recourse = _this.user_info.dispute_recourse;
                    $("#dispute_start").val(_this.user_info.dispute_start);
                    $("#dispute_end").val(_this.user_info.dispute_end);
                    // _this.stats = _this.user_info.friend_status
                    // $("#dispute_stats").find("option:selected").val(_this.user_info.friend_status)
                    // $("#dispute_stats").find("option:selected").val(1);

                    // $("#dispute_stats").find("option[value='1']").attr("selected", 'selected');
                    // console.log($("#dispute_stats"))
                    // console.log($("#dispute_stats").find("option:selected"))
                    // console.log($("#dispute_stats").find("option:selected").val(1))
                    // $("#dispute_stats").attr("value", '1');
                })
                .catch((err) => {});
        },
        //新增方法
        submit: function() {
            const _this = this;
            let obj1 = {
                dispute_recourse: _this.dispute_recourse, //纠纷原因
                dispute_start: $("#dispute_start").val(), //纠纷开始时间
                dispute_end: $("#dispute_end").val(), //纠纷结束时间
                friend_status: $("#dispute_stats").find("option:selected").val(), //纠纷状态
                id: _this.id,
                businessNo: _this.businessNo, //业务识别号（保单号）
            };
            console.log(obj1);
            axios({
                    method: "post",
                    url: App.envUrl.backtrackUrl+"collect/updateCollect",
                    data: obj1,
                })
                .then((data) => {
                    console.log(data);
                    // window.location.href =
                    //     "index1.html"
                    window.location.href = "nrrback.html";
                })
                .catch((err) => {});
        },
        friend_return: function() {
            // window.location.href = App.getBaseUrl() + "sys/task/friendcheck.html";
            window.location.href = "nrrback.html";
        },
    },
});